import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { AttachedSoulBattlefieldResultVo } from "./vo/AttachedSoulBattlefieldResultVo";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { AttachedSoulBattlefielResultRenderer } from "./renderer/AttachedSoulBattlefielResultRenderer";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GBitmap } from "../../../../com/mui/controls/GBitmap";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
//class AttachedSoulBattlefielResultWindow
    
    export  class AttachedSoulBattlefielResultWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(840, 560);
            titleHeight = 26;
            title = Language.getString(28603);
            return;
        }

        /* internal  */onClickConfirmBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.AttachedSoulBattlefielLeave, {"needShowAlert": false}));
            return;
        }

        public set data(arg1: AttachedSoulBattlefieldResultVo)
        {
            this._data = arg1;
            if (this._data && this._isLoadCom) 
            {
                if (this._data.result != 1) 
                {
                    if (this._data.result != 0) 
                    {
                        this._yellowLogo.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaTie);
                        this._blueLogo.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaTie);
                        this._yellowAttachedSoulScore.text = Language.getStringByParam(28619, 70);
                        this._blueAttachedSoulScore.text = Language.getStringByParam(28619, 70);
                    }
                    else 
                    {
                        this._yellowLogo.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaLose);
                        this._blueLogo.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaWin);
                        this._blueAttachedSoulScore.text = Language.getStringByParam(28619, 100);
                        this._yellowAttachedSoulScore.text = Language.getStringByParam(28619, 50);
                    }
                }
                else 
                {
                    this._yellowLogo.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaWin);
                    this._blueLogo.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaLose);
                    this._yellowAttachedSoulScore.text = Language.getStringByParam(28619, 100);
                    this._blueAttachedSoulScore.text = Language.getStringByParam(28619, 50);
                }
                this._yellowScore.text = Language.getStringByParam(28620, arg1.yellowTeamScore);
                this._blueScore.text = Language.getStringByParam(28620, arg1.blueTeamScore);
                this._yellowList.dataProvider = new DataProvider(arg1.yellowData);
                this._blueList.dataProvider = new DataProvider(arg1.blueData);
                this._yellowList.drawNow();
                this._blueList.drawNow();
            }
            return;
        }

        /* internal  */onLoadRes2Handler(): void
        {
            this._isLoadCom = true;
            this.data = this._data;
            return;
        }

        /* internal  */onLoadResHandler(): void
        {
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldYellowBigFlag, 27, 51, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldBlueBigFlag, 27, 291, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldYellowTxt, 75, 122, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldBlueTxt, 73, 361, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldRedBg, 80, 180, this));
            pushUIToDisposeVec(ObjCreate.createGBitmap(ImagesConst.AttachedSoulBattlefieldBlueBg, 77, 420, this));
            this.addChild(this._yellowScore);
            this.addChild(this._yellowAttachedSoulScore);
            this.addChild(this._blueScore);
            this.addChild(this._blueAttachedSoulScore);
            this.addChild(this._yellowLogo);
            this.addChild(this._blueLogo);
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            var loc1=new GTextFormat(FontUtil.songtiName, 14, GlobalStyle.color6Uint, true);
            pushUIToDisposeVec(ObjCreate.createBg(18, 38, 804, 235, this));
            pushUIToDisposeVec(ObjCreate.createBg(18, 277, 804, 235, this));
            pushUIToDisposeVec(ObjCreate.createFlowerBg(27, 50, 160, 210, this));
            pushUIToDisposeVec(ObjCreate.createFlowerBg(27, 290, 160, 210, this));
            this._yellowList = ObjCreate.createTileList(200, 43, 640, 230, this);
            this._yellowList.scrollPolicy = ScrollPolicy.OFF;
            this._yellowList.columnWidth = 320;
            this._yellowList.rowHeight = 75;
            this._yellowList.setStyle("cellRenderer", AttachedSoulBattlefielResultRenderer);
            this._yellowScore = ObjCreate.createGTextField("", 80, 182, 150, 25, this, loc1);
            this._yellowAttachedSoulScore = ObjCreate.createGTextField("", 60, 219, 150, 20, this, GlobalStyle._textFormat5);
            this._yellowLogo = ObjCreate.createGBitmap("", 32, 165, this);
            this._blueList = ObjCreate.createTileList(200, 282, 640, 230, this);
            this._blueList.scrollPolicy = ScrollPolicy.OFF;
            this._blueList.columnWidth = 320;
            this._blueList.rowHeight = 75;
            this._blueList.setStyle("cellRenderer", AttachedSoulBattlefielResultRenderer);
            this._blueScore = ObjCreate.createGTextField("", 80, 422, 150, 20, this, loc1);
            this._blueAttachedSoulScore = ObjCreate.createGTextField("", 60, 459, 150, 20, this, GlobalStyle._textFormat5);
            this._blueLogo = ObjCreate.createGBitmap("", 32, 405, this);
            var loc2=ObjCreate.createGButton(Language.getString(28602), 383, 520, 62, 25, this);
            loc2.configEventListener(flash.events.MouseEvent.CLICK, this.onClickConfirmBtnHandler);
            pushUIToDisposeVec(loc2);
            pushUIToDisposeVec(ObjCreate.createGTextField(Language.getString(28601), 452, 523, 220, 20, this, GlobalStyle._textFormat5));
            pushUIToDisposeVec(ObjCreate.createBg(200, this._yellowList.y + 75, 640, 2, this, ImagesConst.SplitLine));
            pushUIToDisposeVec(ObjCreate.createBg(200, this._yellowList.y + 75 * 2, 640, 2, this, ImagesConst.SplitLine));
            pushUIToDisposeVec(ObjCreate.createBg(200, this._blueList.y + 75, 640, 2, this, ImagesConst.SplitLine));
            pushUIToDisposeVec(ObjCreate.createBg(200, this._blueList.y + 75 * 2, 640, 2, this, ImagesConst.SplitLine));
            LoaderHelp.addResCallBack(ResFileConst.AttachedSoulBattlefield, this.onLoadResHandler);
            LoaderHelp.addResCallBack(ResFileConst.arena, this.onLoadRes2Handler);
            return;
        }

        protected /* override */ disposeImpl(arg1: Boolean=true): void
        {
            super.disposeImpl(arg1);
            this._yellowList.dataProvider = new DataProvider([]);
            this._yellowList.dispose(arg1);
            this._yellowLogo.dispose(arg1);
            this._yellowScore.dispose(arg1);
            this._yellowAttachedSoulScore.dispose(arg1);
            this._blueList.dataProvider = new DataProvider([]);
            this._blueList.dispose(arg1);
            this._blueLogo.dispose(arg1);
            this._blueScore.dispose(arg1);
            this._blueAttachedSoulScore.dispose(arg1);
            this._yellowList = null;
            this._yellowLogo = null;
            this._yellowScore = null;
            this._yellowAttachedSoulScore = null;
            this._blueList = null;
            this._blueLogo = null;
            this._blueScore = null;
            this._blueAttachedSoulScore = null;
            this._data = null;
            this._isLoadCom = false;
            return;
        }

        /* internal */ /* var */_yellowList: GTileList;

        /* internal */ /* var */_yellowLogo: GBitmap;

        /* internal */ /* var */_yellowScore: GTextFiled;

        /* internal */ /* var */_yellowAttachedSoulScore: GTextFiled;

        /* internal */ /* var */_blueList: GTileList;

        /* internal */ /* var */_blueLogo: GBitmap;

        /* internal */ /* var */_blueScore: GTextFiled;

        /* internal */ /* var */_blueAttachedSoulScore: GTextFiled;

        /* internal */ /* var */_data: AttachedSoulBattlefieldResultVo;

        /* internal */ /* var */_isLoadCom: Boolean;
    }
